#ifndef JABSTRACTIO_P_H
#define JABSTRACTIO_P_H

// W A R N I N G
// -------------
// This file is not JXQLIB-APIs

#include "jabstractio.h"
#include <JXQCore/JMutex>
#include <JXQCore/JDebug>
#include <condition_variable>
#include <atomic>
#include <cstdio>

namespace JXQ
{

typedef JAbstractIO::OpenMode    OpenMode;
typedef JAbstractIO::BufferMode  BufferMode;

class JXQLIB_EXPORT JAbstractIOPrivate
{
public:
	explicit JAbstractIOPrivate(JAbstractIO *q_ptr);
	virtual ~JAbstractIOPrivate();

public:
	bool check(OpenMode mode) const;

public:
	JAbstractIO *q_ptr;

	std::mutex m_openMutex;
	bool m_isOpen = false;
	OpenMode m_openMode = JAbstractIO::NotOpen;

	BufferMode m_bufMode = JAbstractIO::FullBuffer;

	std::mutex m_readWaitMutex;
	std::condition_variable m_readCondition;

	std::atomic_bool m_isBusy {false};
	std::atomic_int m_errNum {0};
};

} //namespace JXQ


#endif //JABSTRACTIO_P_H
